-
Couldn't load subscription status.
- Fork 1.5k
removed need for friend declaration of test class in CmdLineParser / cleanups
#7896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
If this is acceptable we probably can use this pattern for other classes which currently require |
| class CmdLineParserTest : public CmdLineParser | ||
| { | ||
| friend class TestCmdlineParser; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows us to access the protected members.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see no nice solution.
- Friend is horrible but at least it explicitly pointed out the test class.
- The disadvantage with this solution is that if we would ever like to use CmdLineParser as a base class in production code then the derived classes have access to stuff that should really be private.
I have no strong opinion. But I fear that sooner or later somebody will come and look at the code and in his opinion we should have solved it in another way and then we get another PR..
I think it is perfectly reasonable in tests. It might even be the proper way to test internals.
Which you could always circumvent by using a Also this allowed us to remove several unnecessary public accesses so you can actually access less things then before from outside the class. In some other cases I already did we can even get rid of the Using the |
|
I could have kept the access functions and moved them to the test classes. Something to consider for future changes like this. |



No description provided.